import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/8/23
 * Time: 17:18
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //1.读入数据
        int n = in.nextInt(),m = in.nextInt();
        int[] arr = new int[n + 1];
        for(int i = 1;i <= n;i++) {
            arr[i] = in.nextInt();
        }
        //2.预处理前缀和数组
        long[] sum = new long[n + 1];//防止数据溢出
        for(int i = 1;i <= n;i++){
            sum[i] = sum[i - 1] + arr[i];
        }
        //3.使用前缀和数组
        while(m > 0){
            int l = in.nextInt(),r = in.nextInt();
            System.out.println(sum[r] - sum[l - 1]);
            m--;
        }
    }
}